import Vue from 'vue'
import Router from 'vue-router'
import App from '../app'
//登录
import login from '../pages/login'
//404
import notfound from '../pages/error/404'
import layout from '../pages/layout'
Vue.use(Router);
/*路由配置*/
/*ps 现在code只控制到菜单
* code中的值是和后台权限控制--页面元素中的code是一一对应的
* */
const router = new Router({
  routes: [

      {
          path:'/',
          redirect:'/login',
      },
      {
          path:'/user',
          meta: { text: '用户管理'},
          component: layout,
          redirect: '/user/list',
          children: [
              {
                  path:'list',
                  meta: { text: '用户管理', code:'user'},
                  component: require('../pages/user/list')
              },
              {
                  path:'add',
                  meta: { text: '新增用户',code:'user'},
                  component: require('../pages/user/add')
              },
              {
                  path:'modify/:id',
                  name: 'modifyUser',
                  meta: { text: '修改用户',code:'user'},
                  component: require('../pages/user/add')
              },
              {
                  path:'otp/:id',
                  name: 'setOTP',
                  meta: { text: '设置 OTP',code:'otp'},
                  component: require('../pages/user/otp')
              }
          ]
      },
      {
          path:'/log',
          meta: { text: '日志管理'},
          component: layout,
          redirect: '/log/list',
          children: [
              {
                path:'list',
                meta: { text: '日志管理', code:'log'},
                component: require('../pages/log/list')
              }
          ]
      },
      {
          path: '/login',
          meta: {auth: false,code:'noNeedPermission'},
          component: login
      }
  ]
  //mode: 'history',
  //base: ''
});

export default router

